//
//  ZLAdministratorView.m
//  ZLExamination
//
//  Created by Zheng on 2017/8/11.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "ZLAdministratorView.h"

@interface ZLAdministratorView ()

@property (nonatomic, strong) UILabel *titleLbl;
@property (nonatomic, strong) UILabel *subTitleLbl;
@property (nonatomic, strong) UIButton *addressBtn;
@property (nonatomic, strong) UIButton *activeBtn;

@end

@implementation ZLAdministratorView

- (void)btnClickAction:(UIButton *)sender {
    if (sender == _addressBtn) {
        if (_addressAction != nil && _addressAction != NULL) {
            _addressAction(_addressBtn);
        }
    }
    
    else if (sender == _activeBtn) {
        if (_activeAction != nil && _activeAction != NULL) {
            _activeAction();
        }
    }
}

#pragma mark - 初始化
- (instancetype)init {
    self = [super init];
    if (self) {
        [self addSubview:self.titleLbl];
        [self addSubview:self.subTitleLbl];
        [self addSubview:self.addressBtn];
        [self addSubview:self.activeBtn];
        
        [_titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(25);
            make.left.mas_equalTo(12);
        }];
        
        [_subTitleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLbl.mas_bottom).offset(35);
            make.centerX.equalTo(self);
        }];
        
        [_addressBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_subTitleLbl.mas_bottom).offset(20);
            make.centerX.equalTo(self);
            make.width.equalTo(self).multipliedBy(0.72);
            make.height.mas_equalTo(45);
        }];
        
        [_activeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_addressBtn.mas_bottom).offset(60);
            make.centerX.equalTo(self);
            make.width.equalTo(self).multipliedBy(0.48);
            make.height.mas_equalTo(40);
        }];
        
    }
    return self;
}

#pragma mark - subviews
- (UILabel *)titleLbl {
    if (!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.text = @"账户激活操作";
        _titleLbl.font = [UIFont boldSystemFontOfSize:15];
    }
    return _titleLbl;
}

- (UILabel *)subTitleLbl {
    if (!_subTitleLbl) {
        _subTitleLbl = [[UILabel alloc] init];
        _subTitleLbl.text = @"请选择需要激活的地区";
        _subTitleLbl.font = kCX_FONT(14);
        _subTitleLbl.textColor = [UIColor darkGrayColor];
    }
    return _subTitleLbl;
}

- (UIButton *)addressBtn {
    if (!_addressBtn) {
        _addressBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_addressBtn setTitle:@"请选择" forState:UIControlStateNormal];
        _addressBtn.titleLabel.font = kCX_FONT(12);
        [_addressBtn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        _addressBtn.layer.borderColor = [[UIColor darkGrayColor] CGColor];
        _addressBtn.layer.borderWidth = 0.5;
        [_addressBtn addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _addressBtn;
}

- (UIButton *)activeBtn {
    if (!_activeBtn) {
        _activeBtn = [UIButton buttonWithType:UIButtonTypeSystem];
        [_activeBtn setTitle:@"确定激活账号" forState:UIControlStateNormal];
        _activeBtn.titleLabel.font = kCX_FONT(13);
        [_activeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _activeBtn.backgroundColor = kMY_BLUE_COLOR;
        _activeBtn.layer.cornerRadius = 5;
        [_activeBtn addTarget:self action:@selector(btnClickAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _activeBtn;
}

@end
